package com.bw.liuyushan.zhuangao4_weektest2.Adapter;

import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bw.liuyushan.zhuangao4_weektest2.Entity.VideoBean;
import com.bw.liuyushan.zhuangao4_weektest2.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * ZhuanGao4_WeekTest2
 * file name is : VideoAdapter
 * created by Ender on 2021/8/23 9:27.
 * author : 刘雨杉
 * Describe(作用):
 */
public class VideoAdapter extends BaseQuickAdapter<VideoBean.DataBean, BaseViewHolder> {
    int i=0;
    public VideoAdapter(@Nullable List<VideoBean.DataBean> data) {
        super(R.layout.video_rvitem, data);
        addChildClickViewIds(R.id.gifts);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, VideoBean.DataBean dataBean) {
        StandardGSYVideoPlayer player = baseViewHolder.findView(R.id.stand);
        player.setUp(dataBean.getVideopath(),false,dataBean.getAuthname());
        if (i==0){
            player.startPlayLogic();
            i++;
        }
        ImageView view = baseViewHolder.findView(R.id.yuan);
        //getContext().getResources().getDrawable(R.drawable.yuan)
        Glide.with(getContext()).load(getContext().getResources().getDrawable(R.drawable.yuan)).circleCrop().into(view);
        ObjectAnimator rotation = ObjectAnimator.ofFloat(view, "rotation", 1, 720);
        rotation.setDuration(2000);
        rotation.setRepeatCount(ValueAnimator.INFINITE);
        rotation.start();

    }
}
